﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace timetableasy.Models
{
    public class ClassManagerUserRepository : UserRepository
    {
        private TimeTableDBDataContext db = new TimeTableDBDataContext();

        //Query Methods
        public IQueryable<ClassManagerUser> FindAllClassManagerUsers()
        {
            return db.ClassManagerUsers;
        }

        public ClassManagerUser GetClassManagerUserById(int id)
        {
            return db.ClassManagerUsers.SingleOrDefault(cmu => cmu.UserIdFK == id);
        }

        //Insert/Delete Methods

        public void Add(ClassManagerUser classManagerUser)
        {
            db.ClassManagerUsers.InsertOnSubmit(classManagerUser);
        }

        public void Delete(ClassManagerUser classManagerUser)
        {
            db.ClassManagerUsers.DeleteOnSubmit(classManagerUser);
        }

        //Persistence

        public void Save()
        {
            db.SubmitChanges();
        }
    }
}